#include"common_material.h"
shared_ptr<BSDF> CommonMaterial::createBSDF(const SurfaceInteraction* si, TransportMode mode)
{
	shared_ptr<BSDF> bsdf(new BSDF(si->t, si->n, eta));
	Spectrum lbt_color = kd->_get_color_at(si->u, si->v);
	if (!lbt_color.IsBlack())
		bsdf->addBxDF(new LambertianReflection(lbt_color));
	Spectrum phong_color = ks->_get_color_at(si->u, si->v);
	if (!phong_color.IsBlack()) {
		int flags = BSDF_GLOSSY | BSDF_REFLECTION;
		if(ns>1000) flags = BSDF_SPECULAR | BSDF_REFLECTION;
		bsdf->addBxDF(new BlinnPhongReflection(phong_color, ns, divided_by_NdotL,flags));
	}
	if (eta > 1.0) {
		bsdf->addBxDF(new SpecularReflection());
		bsdf->addBxDF(new SpecularTransmission(eta));
	}
	return bsdf;
}